<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Resources extends Controller_App {
	
	public function before(){
		parent::before();
		$this->auto_render = false;
	}

	public function action_get($id){
		$resource = Model::factory('resource', $id)->where('store_id', '=', $this->getStore()->id);
		if($resource->loaded()){
			$this->request->headers('Content-type', $resource->content_type);
			$this->request->headers('Content-length', filesize($resource->data));
			$this->request->headers('Cache-control', 'max-age=290304000, must-revalidate');
			$this->request->response = $resource->data;
		}else{
			throw new HTTP_Exception_404('File not found');
		}
	}
	
}
	